#include "SMPPSubmitMulti.hpp"

using namespace smpp::pdu;

SubmitMulti::SubmitMulti(const Header &nHeader,
const CoctetString &nServiceType,
const quint8 nSourceAddrTON,
const quint8 nSourceAddrNPI,
const CoctetString &nSourceAddr,
const quint8 nNumberOfDest,
const QVector<DestAddress> nDestAddress,
const quint8 nEsmClass,
const quint8 nProtocolId,
const quint8 nPriorityFlag,
const CoctetString &nScheduleDeliveryTime,
const CoctetString &nValidityPeriod,
const quint8 nRegisteredDelivery,
const quint8 nReplaceIfPresentFlag,
const quint8 nDataCoding,
const quint8 nSMDefaultMsgId,
const quint8 nSMLength,
const octetString &nShortMessage,
const MessageSubmissionRequestTLVs &nMessageSubmissionRequestTLVs):
Header(nHeader),
_ServiceType(nServiceType),
_SourceAddrTON(nSourceAddrTON),
_SourceAddrNPI(nSourceAddrNPI),
_SourceAddr(nSourceAddr),
_NumberOfDest(nNumberOfDest),
_DestAddress(nDestAddress),
_EsmClass(nEsmClass),
_ProtocolId(nProtocolId),
_PriorityFlag(nPriorityFlag),
_ScheduleDeliveryTime(nScheduleDeliveryTime),
_ValidityPeriod(nValidityPeriod),
_RegisteredDelivery(nRegisteredDelivery),
_ReplaceIfPresentFlag(nReplaceIfPresentFlag),
_DataCoding(nDataCoding),
_SMDefaultMsgId(nSMDefaultMsgId),
_SMLength(nSMLength),
_ShortMessage(nShortMessage),
MessageSubmissionRequestTLVs(nMessageSubmissionRequestTLVs){}

SubmitMulti::SubmitMulti(const SubmitMulti &nSubmitMulti):
Header(nSubmitMulti),
_ServiceType(nSubmitMulti.getServiceType()),
_SourceAddrTON(nSubmitMulti.getSourceAddrTON()),
_SourceAddrNPI(nSubmitMulti.getSourceAddrNPI()),
_SourceAddr(nSubmitMulti.getSourceAddr()),
_NumberOfDest(nSubmitMulti.getNumberOfDest()),
_DestAddress(nSubmitMulti.getDestAddress()),
_EsmClass(nSubmitMulti.getEsmClass()),
_ProtocolId(nSubmitMulti.getProtocolId()),
_PriorityFlag(nSubmitMulti.getPriorityFlag()),
_ScheduleDeliveryTime(nSubmitMulti.getScheduleDeliveryTime()),
_ValidityPeriod(nSubmitMulti.getValidityPeriod()),
_RegisteredDelivery(nSubmitMulti.getRegisteredDelivery()),
_ReplaceIfPresentFlag(nSubmitMulti.getReplaceIfPresentFlag()),
_DataCoding(nSubmitMulti.getDataCoding()),
_SMDefaultMsgId(nSubmitMulti.getSMDefaultMsgId()),
_SMLength(nSubmitMulti.getSMLength()),
_ShortMessage(nSubmitMulti.getShortMessage()),
MessageSubmissionRequestTLVs(nSubmitMulti){}

void SubmitMulti::setServiceType(const CoctetString &sServiceType){
	_ServiceType = sServiceType;
}

const CoctetString &SubmitMulti::getServiceType() const{
	return _ServiceType;
}

void SubmitMulti::setSourceAddrTON(const quint8 nSourceAddrTON){
	_SourceAddrTON = nSourceAddrTON;
}

const quint8 SubmitMulti::getSourceAddrTON() const{
	return _SourceAddrTON;
}

void SubmitMulti::setSourceAddrNPI(const quint8 nSourceAddrNPI){
	_SourceAddrNPI = nSourceAddrNPI;
}

const quint8 SubmitMulti::getSourceAddrNPI() const{
	return _SourceAddrNPI;
}

void SubmitMulti::setSourceAddr(const CoctetString &sSourceAddr){
	_SourceAddr = sSourceAddr;
}

const CoctetString &SubmitMulti::getSourceAddr() const{
	return _SourceAddr;
}

void SubmitMulti::setNumberOfDest(const quint8 nNumberOfDest){
	_NumberOfDest = nNumberOfDest;
}

const quint8 SubmitMulti::getNumberOfDest() const{
	return _NumberOfDest;
}

void SubmitMulti::addDestAddress(const DestAddress &nDestAddress){
	_DestAddress.push_back(nDestAddress);
}

void SubmitMulti::setDestAddress(
	const QVector<DestAddress> &nDestAddress){
	_DestAddress = nDestAddress;
}

const QVector<DestAddress> &SubmitMulti::getDestAddress() const{
	return _DestAddress;
}

void SubmitMulti::setEsmClass(const quint8 nEsmClass){
	_EsmClass = nEsmClass;
}

const quint8 SubmitMulti::getEsmClass() const{
	return _EsmClass;
}

void SubmitMulti::setProtocolId(const quint8 nProtocolId){
	_ProtocolId = nProtocolId;
}

const quint8 SubmitMulti::getProtocolId() const{
	return _ProtocolId;
}

void SubmitMulti::setPriorityFlag(const quint8 nPriorityFlag){
	_PriorityFlag = nPriorityFlag;
}

const quint8 SubmitMulti::getPriorityFlag() const{
	return _PriorityFlag;
}

void SubmitMulti::setScheduleDeliveryTime(
	const CoctetString &sScheduleDeliveryTime){
	_ScheduleDeliveryTime = sScheduleDeliveryTime;
}

const CoctetString &SubmitMulti::getScheduleDeliveryTime() const{
	return _ScheduleDeliveryTime;
}

void SubmitMulti::setValidityPeriod(
	const CoctetString &sValidityPeriod){
	_ValidityPeriod = sValidityPeriod;
}

const CoctetString &SubmitMulti::getValidityPeriod() const{
	return _ValidityPeriod;
}

void SubmitMulti::setRegisteredDelivery(
	const quint8 nRegisteredDelivery){
	_RegisteredDelivery = nRegisteredDelivery;
}

const quint8 SubmitMulti::getRegisteredDelivery() const{
	return _RegisteredDelivery;
}

void SubmitMulti::setReplaceIfPresentFlag(
	const quint8 nReplaceIfPresentFlag){
	_ReplaceIfPresentFlag = nReplaceIfPresentFlag;
}

const quint8 SubmitMulti::getReplaceIfPresentFlag() const{
	return _ReplaceIfPresentFlag;
}

void SubmitMulti::setDataCoding(const quint8 nDataCoding){
	_DataCoding = nDataCoding;
}

const quint8 SubmitMulti::getDataCoding() const{
	return _DataCoding;
}

void SubmitMulti::setSMDefaultMsgId(const quint8 nSMDefaultMsgId){
	_SMDefaultMsgId = nSMDefaultMsgId;
}

const quint8 SubmitMulti::getSMDefaultMsgId() const{
	return _SMDefaultMsgId;
}

void SubmitMulti::setSMLength(const quint8 nSMLength){
	_SMLength = nSMLength;
}

const quint8 SubmitMulti::getSMLength() const{
	return _SMLength;
}

void SubmitMulti::setShortMessage(const octetString &aShortMessage){
	_ShortMessage = aShortMessage;
}

const octetString &SubmitMulti::getShortMessage() const{
	return _ShortMessage;
}

void SubmitMulti::calcCommandLength(){
	_CommandLength = 27 + _ServiceType.size() + _SourceAddr.size() +
		_ScheduleDeliveryTime.size() + _ValidityPeriod.size() + 
		_ShortMessage.size() + MessageSubmissionRequestTLVs::getLength();
	for(int i = 0;i<_DestAddress.size();i++)
		_CommandLength += _DestAddress[i].getLength();
}
